package com.sitanyun.merchant.guide.frament.model.impl;

import com.google.gson.Gson;
import com.sitanyun.merchant.guide.bean.WxImagesBean;
import com.sitanyun.merchant.guide.callback.StringCallbacks;
import com.sitanyun.merchant.guide.frament.model.inter.IWxImageAModel;
import com.sitanyun.merchant.guide.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.url.Urls;
import com.sitanyun.merchant.guide.weiht.SharedPreferenceUtil;
import com.zhy.http.okhttp.OkHttpUtils;

import okhttp3.Call;

/**
 * WX二维码
 */
public class WxImageAModelImpl implements IWxImageAModel {
    @Override
    public <T> void setqrcodeId(String qrcodeId, CallBack callBack) {
        OkHttpUtils.get().url(Urls.wximgge+"?qrcodeId="+qrcodeId)
                .addHeader("Content-Type","application/json")
                .addHeader("Authorization","Bearer "+ SharedPreferenceUtil.getStringData("token"))

                .build().execute(new StringCallbacks() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                WxImagesBean baseEntity = new Gson().fromJson(response,WxImagesBean.class);
                callBack.onSuccess(baseEntity);
            }
        });
    }
}
